package JackSu.project_model;

/**
 * SimpleFactoryTest
 *
 * @author Syzer
 * @Description 简单工厂模式
 * @Date 2021/7/8 16:21
 */
public class SimpleFactoryTest {

    private interface Product {
        void show();
    }

    private static class IProduct implements Product {
        @Override
        public void show() {
            System.out.println("具体产品1");
        }
    }

    private static class QProduct implements Product {
        @Override
        public void show() {
            System.out.println("具体产品2");
        }
    }

    private static Product factory(int param) {
        switch(param) {
            case 0:
                return new IProduct();
            case 1:
                return new QProduct();
            default:
                return null;
        }
    }

    public static void main(String[] args) {
        Product factory = factory(0);
        factory.show();
        Product factory1 = factory(1);
        factory1.show();
    }
}
